home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / TinyGL / ami / content / ad709 / tinygl / examples / c / basicframework.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-15  |  1.4 KB  |  51 lines

  1. /*************************************
  2. *  Basic framework example. This simply opens an OpenGL window and adds 
  3. *  an idle function, that simply redisplays the window
  4. *
  5. ************/
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. /* This is the TinyGL standard GLUT header. glut.h already includes gl.h and glu.h
  11. so there is no need to include those */
  12. #include <ad709/tinygl/glut.h>
  13.  
  14. int glutWindow;
  15.  
  16. /* Some GL initializations. In this case, only setting the clear color to black */
  17. void init(void)     {
  18.     glClearColor(0.0, 0.0, 0.0, 0.0) ;
  19. }
  20.  
  21.  
  22. /* The display function just clears the background
  23. NOTE: Since our window is using a single buffer, we don't need to call glutSwapBuffers here */
  24. void display(void)    {
  25.     glClear(GL_COLOR_BUFFER_BIT);
  26. }
  27.  
  28.  
  29. /* The idle function can be used for parts of code that don't depend on user input 
  30. (for example, automatic animations or sounds). In the end we need to update the window contents. */
  31. void idle() {
  32.     glutPostRedisplay();
  33. }
  34.  
  35.  
  36. int main(int argc, char** argv)    {
  37.     /* Some initilizations for GLUT and our window bounds */
  38.     glutInit(&argc, argv);
  39.     glutInitWindowSize(320, 240);
  40.     glutInitWindowPosition(0, 0);
  41.     glutWindow = glutCreateWindow("Basic OpenGL app") ;
  42.     init();
  43.     /* Registering the callback functions */
  44.     glutDisplayFunc(display);
  45.     glutIdleFunc(idle);
  46.     /* Entering the GLUT main loop */
  47.     glutMainLoop();
  48.  
  49.     return 0 ;
  50. }
  51.